#include<math.h>
class Solution {
public:
    int findComplement(int num) {
        int pos = 0;
        for(int i = 31; i >= 0; --i){
            int flag = (1 << i);
            if((flag & num) != 0){
                pos = i;
                break;
            }
        }
        int Bit_ReverseNum = ~num;
        int tmp = (1 << pos) + ((int)pow(2, pos) - 1);
        return Bit_ReverseNum & tmp;
    }
};
